/**
 * Created by TRwin7SP1 on 2016/8/23.
 */
angular.module('inspinia')
  .controller('directorCtrl', function ($scope) {
    var myChart = echarts.init(document.getElementById('main'));
    var myCahrtActual = echarts.init(document.getElementById('actual'));
    var myChartPlan = echarts.init(document.getElementById('plan'));



    // 指定图表的配置项和数据
    var option = {
      title: {
        text: '昨日加速器统计表'
      },
      tooltip: {},
      legend: {
        data:['计划','实际']
      },
      xAxis: {
        data: ["1号机","2号机","3号机","4号机","5号机","6号机","7号机","8号机","9号机"]
      },
      yAxis: {},
      series: [{
        name: '计划',
        type: 'line',
        data: [50, 20, 36, 10, 10, 20,45, 8,41]
      },{
        name: '实际',
        type: 'bar',
        data: [9, 18, 30, 20, 15, 28,40, 18,23]
      }]
    };



    // 指定图表的配置项和数据
    var actualOption = {
      title: {
        text: '1号加速器上周实际与计划对比图'
      },
      tooltip: {},
      legend: {
        data:['计划','实际']
      },
      xAxis: {
        data: ["星期一","星期二","星期三","星期四","星期五","星期六","星期天"]
      },
      yAxis: {},
      series: [{
        name: '计划',
        type: 'line',
        data: [5, 20, 36, 10, 10, 20,45]
      },{
        name: '实际',
        type: 'bar',
        data: [9, 18, 30, 20, 15, 28,40]
      }]
    };



    // 指定图表的配置项和数据
    var planOption = {
      title: {
        text: '1号加速器本周实际与计划对比图'
      },
      tooltip: {},
      legend: {
        data:['计划','实际']
      },
      xAxis: {
        data: ["星期一","星期二","星期三","星期四","星期五","星期六","星期天"]
      },
      yAxis: {},
      series: [{
        name: '计划',
        type: 'line',
        data: [20, 20, 36, 10, 10, 20,45]
      },{
        name: '实际',
        type: 'bar',
        data: [15, 18, 30]
      }]
    };







    // 使用刚指定的配置项和数据显示图表。
    myChart.setOption(option);
    myCahrtActual.setOption(actualOption);
    myChartPlan.setOption(planOption);



    /**
     * dashboardFlotTwo - simple controller for data
     * for Flot chart in Dashboard view
     */







      var dataset = [
        {
          label: "Number of orders",
          grow:{stepMode:"linear"},
          data: data2,
          color: "#1ab394",
          bars: {
            show: true,
            align: "center",
            barWidth: 24 * 60 * 60 * 600,
            lineWidth: 0
          }

        },
        {
          label: "Payments",
          grow:{stepMode:"linear"},
          data: data1,
          yaxis: 2,
          color: "#1C84C6",
          lines: {
            lineWidth: 1,
            show: true,
            fill: true,
            fillColor: {
              colors: [
                {
                  opacity: 0.2
                },
                {
                  opacity: 0.2
                }
              ]
            }
          }
        }
      ];


      var options = {
        grid: {
          hoverable: true,
          clickable: true,
          tickColor: "#d5d5d5",
          borderWidth: 0,
          color: '#d5d5d5'
        },
        colors: ["#1ab394", "#464f88"],
        tooltip: true,
        xaxis: {
          mode: "time",
          tickSize: [3, "day"],
          tickLength: 0,
          axisLabel: "Date",
          axisLabelUseCanvas: true,
          axisLabelFontSizePixels: 12,
          axisLabelFontFamily: 'Arial',
          axisLabelPadding: 10,
          color: "#d5d5d5"
        },
        yaxes: [
          {
            position: "left",
            max: 1070,
            color: "#d5d5d5",
            axisLabelUseCanvas: true,
            axisLabelFontSizePixels: 12,
            axisLabelFontFamily: 'Arial',
            axisLabelPadding: 3
          },
          {
            position: "right",
            color: "#d5d5d5",
            axisLabelUseCanvas: true,
            axisLabelFontSizePixels: 12,
            axisLabelFontFamily: ' Arial',
            axisLabelPadding: 67
          }
        ],
        legend: {
          noColumns: 1,
          labelBoxBorderColor: "#d5d5d5",
          position: "nw"
        }

      };

      function gd(year, month, day) {
        return new Date(year, month - 1, day).getTime();
      }

      /**
       * Definition of variables
       * Flot chart
       */
      this.flotData = dataset;
    this.flotOptions = options;



    /**
     * Options for Bar chart
     */
    this.barOptions = {
      scaleBeginAtZero : true,
      scaleShowGridLines : true,
      scaleGridLineColor : "rgba(0,0,0,.05)",
      scaleGridLineWidth : 1,
      barShowStroke : true,
      barStrokeWidth : 2,
      barValueSpacing : 5,
      barDatasetSpacing : 1
    };

    /**
     * Data for Bar chart
     */
    this.barData = {
      labels: ["星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期天"],
      datasets: [
        {
          label: "My First dataset",
          fillColor: "rgba(220,0,220,0.5)",
          strokeColor: "rgba(220,0,220,0.8)",
          highlightFill: "rgba(220,0,220,0.75)",
          highlightStroke: "rgba(220,0,220,1)",
          data: [81, 45, 70, 34, 67, 23, 67]
        },

        {
          label: "My First dataset",
          fillColor: "rgba(220,220,0,0.5)",
          strokeColor: "rgba(220,220,0,0.8)",
          highlightFill: "rgba(220,220,0,0.75)",
          highlightStroke: "rgba(220,220,0,1)",
          data: [23, 65, 49, 90, 34, 80, 45]
        },


        {
          label: "My First dataset",
          fillColor: "rgba(220,220,220,0.5)",
          strokeColor: "rgba(220,220,220,0.8)",
          highlightFill: "rgba(220,220,220,0.75)",
          highlightStroke: "rgba(220,220,220,1)",
          data: [65, 59, 80, 81, 56, 55, 40]
        },


        {
          label: "My Second dataset",
          fillColor: "rgba(26,179,148,0.5)",
          strokeColor: "rgba(26,179,148,0.8)",
          highlightFill: "rgba(26,179,148,0.75)",
          highlightStroke: "rgba(26,179,148,1)",
          data: [28, 48, 40, 19, 86, 27, 90]
        }
      ]
    };
    $scope.persons = [
      {
        id:'001',
        text:'计划压模人数',
        name:'plan',
        count:50,
      },
      {
        id:'002',
        text:'已压模人数',
        name:'finished',
        count:30,
      },
      {
        id:'003',
        text:'未压模人数',
        name:'unfinished',
        count:20,
      }
    ];
  });
